inputfiles="F:\HSSBeam.txt"

# ====================== Output tcl files ====================
outputfiles="D:\\PyProgram\\MeshCombinedload.tcl"

# ====================== Input completes =====================
AllNodeList=[]
content=open(inputfiles)
NodeList=[]
SelectedList=[]
for line in content:
    splited=line.split()
    if len(splited)>0:
        if splited[0]=='node':
            NodeList.append([int(splited[1]),float(splited[2]),float(splited[3]),float(splited[4])])
            #Selection Condition
            if abs(float(splited[4]))<1e-5 and abs(float(splited[2])-2.5)<1e-5:
                SelectedList.append(int(splited[1]))
            
AllNodeList.append(NodeList)
content.close()
print(SelectedList)
print('Total:',len(SelectedList))

newf=open(outputfiles,'w')
newf.write('pattern Plain 100 Linear {')
newf.write('\n')
for i in range(0,len(SelectedList)):
    newf.write('load %d 0 0 -1000 0 0 0'%SelectedList[i])
    newf.write('\n')
newf.write('}')
